﻿using System;
using System.Collections.Generic;
using System.Text;

using Volo.Abp.Domain.Entities.Auditing;

namespace YunDrug.EmployeeAuthorization
{ 
    /// <summary>
    /// 机构信息
    /// </summary>
   public  class Organ:AuditedAggregateRoot<Guid>
    {
        public Organ()
        {

        }

        public Organ(Guid upperId, int sort, string name, string describe)
        {
            UpperId = upperId;
            Sort = sort;
            Name = name ?? throw new ArgumentNullException(nameof(name));
            Describe = describe ?? throw new ArgumentNullException(nameof(describe));
            Employees = new List<OrganEmployee>();
            Roles = new List<OrganRole>();
        }

        /// <summary>
        /// 上层机构编码
        /// </summary>
        public Guid UpperId { get; set; }
        /// <summary>
        /// 机构排序
        /// </summary>
        public int Sort { get; set; }
        /// <summary>
        /// 机构名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 机构描述
        /// </summary>
        public string Describe { get; set; }
        /// <summary>
        /// 机构拥有的角色
        /// </summary>
        public virtual List<OrganRole> Roles { get;protected set; }


        /// <summary>
        /// 机构拥有的用户
        /// </summary>
        public virtual List<OrganEmployee> Employees { get; protected set; }
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="roleid"></param>
        public void AddRole(Guid roleid)
        {
            Roles.Add(new OrganRole(this.Id, roleid));
        }
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="employeeid"></param>
        public void AddEmployee(Guid employeeid)
        {
            Employees.Add(new OrganEmployee(this.Id, employeeid));
        }
       
    }
}
